var mongoose = require('mongoose')

var BookSchema = new mongoose.Schema({
  name: String,
  autor: String,
  price: Number,
  publishAt: String,
  createAt: String
})

BookSchema.statics = {
  fetch: function (cb) {
    return this.find({}).sort('createAt').exec(cb)
  },
  findBy: function (id, cb) {
    return this.find({_id, id}).exec(cb)
  }
}

module.exports = BookSchema;